import React, { useState, useRef, useEffect } from 'react'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'
import { connect } from 'umi'
import { getNoticePage,routeJump} from '../service'
import moment from 'moment'
import '../../index.less'

const TableList = () => {
  const actionRef = useRef()
  const columns = [
    {
      title: '消息主键',
      dataIndex: 'id',
      key:'id',
      hideInSearch: true
    },
    {
      title: '消息标题',
      dataIndex: 'title',
      key:'title',
    },
    {
      title: '员工id',
      dataIndex: 'oid',
      key:'oid',
      hideInSearch: true,
    },
    {
      title: '员工姓名',
      dataIndex: 'name',
      key:'name',
      hideInSearch: true,
    },
    {
      title: '待办类型',
      dataIndex: 'type',
      key:'type',
      valueEnum: {
        1: { text: '待入职'},
        2: { text: '待审计'},
        3: { text: '待转正'},
        4: { text: '待签合同'},
        5: { text: '转正待定薪'},
        6: { text: '待录用'},
      },
    },
    {
      title: '处理状态',
      dataIndex: 'isDone',
      key:'isDone',
      valueEnum: {
        0: {text: '未处理', status: 'Processing'},
        1: {text: '已处理', status: 'Success'},
      }
    },
    {
      title: '消息状态',
      dataIndex: 'isRead',
      key:'isRead',
      hideInSearch: true,
      valueEnum: {
        0: { text: '未读', status: 'Processing' },
        1: { text: '已读', status: 'Success' },
      },
    },
    {
      title: '拟定时间',
      dataIndex: 'todoDate',
      key:'todoDate',
      hideInSearch: true,
      render: (text) => {
        return text != '-' ? moment(text).format('YYYY-MM-DD') : ''
      },
    },
  ]

  return (
    <PageHeaderWrapper className="workplace">
        <ProTable className='message-cursor'
          actionRef={actionRef}
          rowKey="id"
          request={(params) => getNoticePage(params)}
          columns={columns}
          options={false}
          onRow={record => {
              return {onClick: (() => routeJump(record))}
            }
          }
        />
    </PageHeaderWrapper>
  )
}

export default connect(() => ({
}))(TableList)
